package com.affectu.task.action;

import java.util.List;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.jboss.seam.annotations.Name;

import com.affectu.dao.DAOBase;
import com.affectu.task.Task;

/**
 * 2008-8-15
 * 
 * @author daniel nathan
 */
@Name("taskAction")
public class TaskAction extends DAOBase {

	private List<Task> tasks;

	@SuppressWarnings("unchecked")
	@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	public List<Task> getTasks() {
		try {
			tasks = em.createSQLQuery(
					"select t.* from Tasks t order by t.publishDate desc")
					.addEntity("t", Task.class).list();// 默认行为
		} catch (Exception ex) {
			this.logException(ex);
		}
		return tasks;
	}

	public void destroy() {

	}
}
